# Copyright (c) 2017 Presto Labs Pte. Ltd.
# Author: jshin


class OrderAmountChecker(object):
  def __init__(self, currency, min_amount, max_amount):
    self.currency = currency
    self.min_amount = float(min_amount)
    self.max_amount = float(max_amount)
    assert self.min_amount > 0
    assert self.max_amount < 1e9
    assert self.min_amount < self.max_amount

  def check_amount(self, currency, price, qty):
    assert type(price) in (int, float, str)
    assert type(qty) in (int, float, str)
    assert self.currency == currency
    amount = float(price) * float(qty)
    assert self.min_amount <= amount, (self.min_amount, amount)
    assert self.max_amount >= amount, (self.max_amount, amount)
    return amount
